import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.GpioPinPwmOutput;
import com.pi4j.io.gpio.Pin;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;
import com.pi4j.util.CommandArgumentParser;
import com.pi4j.util.Console;
import com.raspoid.PWMPin;
import com.raspoid.additionalcomponents.servomotor.TowerProMG90S;


public class zhiliudianji {

	public static void main(String[] args) throws InterruptedException {
		System.out.println("<--Pi4J--> GPIO Control Example ... started.");

        // create gpio controller
//		for (int i = 0; i < 3; i++) {
			 final GpioController gpio = GpioFactory.getInstance();
		        // provision gpio pin #01 as an output pin and turn on
			 	Pin pin8 = CommandArgumentParser.getPin(
		                RaspiPin.class,    // pin provider class to obtain pin instance from
		                RaspiPin.GPIO_24,  // default pin if no pin argument found
		                args);
			 	Pin pin9 = CommandArgumentParser.getPin(
		                RaspiPin.class,    // pin provider class to obtain pin instance from
		                RaspiPin.GPIO_25,  // default pin if no pin argument found
		                args);
		        final GpioPinDigitalOutput out8 = gpio.provisionDigitalOutputPin(pin8, "MyLED", PinState.LOW);
		        final GpioPinDigitalOutput out9 = gpio.provisionDigitalOutputPin(pin9, "MyLED", PinState.LOW);



		        // you can optionally use these wiringPi methods to further customize the PWM generator
		        // see: http://wiringpi.com/reference/raspberry-pi-specifics/

		        // set the PWM rate to 500
		       
		        
		        // set shutdown state for this pin
		        out8.setShutdownOptions(true, PinState.LOW);
		        out9.setShutdownOptions(true, PinState.LOW);
		        Thread.sleep(1000);
//		        pin1.setState(PinState.LOW);
//		            System.out.println("--> GPIO state should be: ON");
//		            Thread.sleep(5000);
//		        if(args[0].equals(0)){
		        final Console console = new Console();
		        console.promptForExit();
		        out8.setState(PinState.HIGH);
	        	out9.setState(PinState.LOW);
	        	Thread.sleep(2000);
	        	out8.setState(PinState.HIGH);
	        	out9.setState(PinState.HIGH);
	        	Thread.sleep(2000);
		        gpio.unprovisionPin(out8,out9);
		        	
		        gpio.shutdown();
//		        System.out.println("--> GPIO shutdown!!");
//		}
       

	}
}
